<?php
/* @var $this XdvertController */
/* @var $model Xdvert */
/* @var $form CActiveForm */ 

?>
<script type="text/javascript">
    $(document).ready(function(e) {
       showview();
       $('#xdtype').change(function(){
       		showview();
       });
      
    });  
    function showview(){
    	var xdtype = $('#xdtype').val();
    	if(xdtype==0 ||xdtype==2 ){
    		$('#videoview').attr('style','display:none;')
    		$('#pictureurl').attr('style','display:;')
    		$('#pictureview').attr('style','display:;')
    	}else{
    		$('#videoview').attr('style','display:;')
    		$('#pictureurl').attr('style','display:none;')
    		$('#pictureview').attr('style','display:none;')
    	}
    }
</script>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'xdvert-form',
	'enableAjaxValidation'=>false,
	'htmlOptions' => array('enctype'=>'multipart/form-data'),
)); ?>

	<p class="note"><span class="required">*</span> 是必填内容.</p> 

	<?php //echo $form->errorSummary($model); ?>

	<div class="row">
		<?php if(Yii::app()->user->name=='admin'){?>  
			<?php echo $form->labelEx($model,'companyid'); ?>
			<?php echo $form->dropDownList(
	              $model,
	              'companyid', 
	            CHtml::listData(
	                Company::model()->findAll(),
	                'id',
	                'title'
	            )
	        ); ?> 
		
		<?php }else{
			echo $form->hiddenField($model,'companyid',array('value'=>Yii::app()->user->id));
		}?>
	</div>

     <div class="row">
        <?php echo $form->labelEx($model,'title'); ?>
          <?php echo $form->textField($model,'title');?> 
        <?php echo $form->error($model,'title'); ?>
    </div>

	<div class="row"> 
		<?php echo $form->hiddenField($model,'xdtype',array('id'=>'xdtype')); ?>
	</div>
 	 
	<div class="row" id="pictureurl">
		<?php echo $form->labelEx($model,'picture'); ?>
		<?php echo CHtml::activeFileField($model,'picture'); ?>
        <?php echo CHtml::label($filetype,false); ?>
		<?php echo $form->error($model,'picture'); ?>
	</div>

	<div class='row' id="pictureview"> 
        <?php  
          if($model->picture !==null){
          	echo CHtml::label("图片预览",false); 
          	echo CHtml::image(Yii::app()->baseUrl.$model->picture,'',array("width"=>"450px")); 
          }  
         ?>
    </div>
    <div class="row" id="videoview" style="display: none;">

		<?php  echo CHtml::label(" ",false);?> 
		<?php  echo "保存完成后,将要上传的视频文件发给客服人员,请注明企业名,广告说明." ;?> 
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'url'); ?>
		<?php echo $form->textField($model,'url',array('maxlength'=>126)); ?>
		<?php echo $form->error($model,'url'); ?>
	</div>

	<div class="row" >
		<?php echo $form->checkBox($model,'usable',array('style'=>'width:16px!important;')); ?>
		<?php echo $form->label($model,'usable'); ?>
		<?php echo $form->error($model,'usable'); ?>
	</div> 

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '新增' : '修改',array('class'=>'subButton')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->